package com.dao;


import com.domain.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

@Mapper
@Component
public interface  UserDao {
//      @Results 用于填写结果集的多个字段的映射关系.
//      @Result 用于填写结果集的单个字段的映射关系.
//      @ResultMap 根据ID关联XML里面<resultMap>.

    /**
     *
     * @return List<user>
     */
    @Select("SELECT * FROM user")
    List<User> getALlUser();

    @Select("SELECT * FROM user WHERE id = #{id}")
    User findById(int id);

    @Insert("INSERT INTO user(name,age) VALUES (#{name},#{age})")
    int insertUser(User user);

    @Update("UPDATE user SET name=#{name},age=#{age} WHERE id =#{id}")
    int updateUser(User user);

    @Delete("DELETE FROM user WHERE id = #{id}")
    void delete(int id);




}
